package es.deusto.eside.programacion4.mario2d.model;

import org.newdawn.slick.Animation;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.Game;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;

/**
 * Personaje principal
 * 
 * @author Sergio
 * 
 */
public class Mario extends BasicCharacter {

	/**
	 * Animacion
	 */
	private Animation walkBig, walkFire, jumpSmall, jumpBig, jumpFire, dead,
			walkBigBehind, walkFireBehind, jumpSmallBehind, jumpFireBehind,
			jumpBigBehind;

	/**
	 * Estado mario
	 */
	boolean fire = false, big = false;
	boolean jump = false;

	/**
	 * @return the jump
	 */
	public boolean isJump() {
		return jump;
	}

	/**
	 * @return the fire
	 */
	public boolean isFire() {
		return fire;
	}

	/**
	 * @param fire
	 *            the fire to set
	 */
	public void setFire(boolean fire) {
		this.fire = fire;
	}

	/**
	 * @return the big
	 */
	public boolean isBig() {
		return big;
	}

	/**
	 * @param big
	 *            the big to set
	 */
	public void setBig(boolean big) {
		this.big = big;
	}

	/**
	 * @param jump
	 *            the jump to set
	 */
	public void setJump(boolean jump) {
		this.jump = jump;
	}

	/**
	 * @return the walkBigBehind
	 */
	public Animation getWalkBigBehind() {
		return walkBigBehind;
	}

	/**
	 * @param walkBigBehind
	 *            the walkBigBehind to set
	 */
	public void setWalkBigBehind(Animation walkBigBehind) {
		this.walkBigBehind = walkBigBehind;
	}

	/**
	 * @return the walkFireBehind
	 */
	public Animation getWalkFireBehind() {
		return walkFireBehind;
	}

	/**
	 * @param walkFireBehind
	 *            the walkFireBehind to set
	 */
	public void setWalkFireBehind(Animation walkFireBehind) {
		this.walkFireBehind = walkFireBehind;
	}

	/**
	 * Constructor
	 * 
	 * @throws SlickException
	 */
	public Mario() throws SlickException {
		super(new SpriteSheet("resources/SpriteSheet/Mario/walkMini.png", 16,
				17), 0, 0, 2, 150);
		animationJumpSMall();
		animationBig();
		animationFire();
	}

	/**
	 * Crea las animaciones de fuego
	 * 
	 * @throws SlickException
	 */
	public void animationFire() throws SlickException {
		SpriteSheet s = new SpriteSheet(
				"resources/SpriteSheet/Mario/fireWalk.png", 17, 31);
		int frames = 2;
		walkFire = new Animation();
		walkFireBehind = new Animation();
		jumpFire = new Animation();
		for (int i = 0; i < frames; i++) {
			this.walkFire.addFrame(s.getSprite(i, 0), 100);
			this.walkFireBehind.addFrame(
					s.getSprite(i, 0).getFlippedCopy(true, false), 100);
		}
		walkBig.setAutoUpdate(true);
		walkBigBehind.setAutoUpdate(true);
		jumpFireBehind = new Animation();
		SpriteSheet sJump = new SpriteSheet(
				"resources/SpriteSheet/Mario/fireJump.png", 17, 31);
		frames = 1;
		for (int i = 0; i < frames; i++) {
			this.jumpFire.addFrame(sJump.getSprite(i, 0), 100);
			this.jumpFireBehind.addFrame(
					sJump.getSprite(i, 0).getFlippedCopy(true, false), 100);

		}
		jumpBig.setAutoUpdate(true);

	}

	/**
	 * Crea las animaciones de Mario "grande"
	 * 
	 * @throws SlickException
	 */
	public void animationBig() throws SlickException {
		SpriteSheet s = new SpriteSheet(
				"resources/SpriteSheet/Mario/bigWalk.png", 17, 31);
		int frames = 2;
		walkBig = new Animation();
		walkBigBehind = new Animation();
		jumpBig = new Animation();
		for (int i = 0; i < frames; i++) {
			this.walkBig.addFrame(s.getSprite(i, 0), 100);
			this.walkBigBehind.addFrame(
					s.getSprite(i, 0).getFlippedCopy(true, false), 100);
		}
		walkBig.setAutoUpdate(true);
		walkBigBehind.setAutoUpdate(true);
		jumpBigBehind = new Animation();
		SpriteSheet sJump = new SpriteSheet(
				"resources/SpriteSheet/Mario/jumpBig.png", 17, 31);
		frames = 1;
		for (int i = 0; i < frames; i++) {
			this.jumpBig.addFrame(sJump.getSprite(i, 0), 100);
			this.jumpBigBehind.addFrame(
					sJump.getSprite(i, 0).getFlippedCopy(true, false), 100);

		}
		jumpBig.setAutoUpdate(true);

	}

	/**
	 * Crea animacion salto
	 * 
	 * @throws SlickException
	 */
	public void animationJumpSMall() throws SlickException {
		SpriteSheet s = new SpriteSheet(
				"resources/SpriteSheet/Mario/jumpSmall.png", 28, 29);
		int frames = 1;
		jumpSmall = new Animation();
		jumpSmallBehind = new Animation();
		for (int i = 0; i < frames; i++) {
			this.jumpSmall.addFrame(s.getSprite(i, 0), 100);
			this.jumpSmallBehind.addFrame(
					s.getSprite(i, 0).getFlippedCopy(true, false), 100);
		}
		jumpSmall.setAutoUpdate(true);
		jumpSmallBehind.setAutoUpdate(true);
	}

	/**
	 * @return the walkBig
	 */
	public Animation getWalkBig() {
		return walkBig;
	}

	/**
	 * @return the jumpSmallBehind
	 */
	public Animation getJumpSmallBehind() {
		return jumpSmallBehind;
	}

	/**
	 * @param jumpSmallBehind
	 *            the jumpSmallBehind to set
	 */
	public void setJumpSmallBehind(Animation jumpSmallBehind) {
		this.jumpSmallBehind = jumpSmallBehind;
	}

	/**
	 * @return the jumpFireBehind
	 */
	public Animation getJumpFireBehind() {
		return jumpFireBehind;
	}

	/**
	 * @param jumpFireBehind
	 *            the jumpFireBehind to set
	 */
	public void setJumpFireBehind(Animation jumpFireBehind) {
		this.jumpFireBehind = jumpFireBehind;
	}

	/**
	 * @return the jumpBigBehind
	 */
	public Animation getJumpBigBehind() {
		return jumpBigBehind;
	}

	/**
	 * @param jumpBigBehind
	 *            the jumpBigBehind to set
	 */
	public void setJumpBigBehind(Animation jumpBigBehind) {
		this.jumpBigBehind = jumpBigBehind;
	}

	/**
	 * @param walkBig
	 *            the walkBig to set
	 */
	public void setWalkBig(Animation walkBig) {
		this.walkBig = walkBig;
	}

	/**
	 * @return the walkFire
	 */
	public Animation getWalkFire() {
		return walkFire;
	}

	/**
	 * @param walkFire
	 *            the walkFire to set
	 */
	public void setWalkFire(Animation walkFire) {
		this.walkFire = walkFire;
	}

	/**
	 * @return the jumpSmall
	 */
	public Animation getJumpSmall() {
		return jumpSmall;
	}

	/**
	 * @param jumpSmall
	 *            the jumpSmall to set
	 */
	public void setJumpSmall(Animation jumpSmall) {
		this.jumpSmall = jumpSmall;
	}

	/**
	 * @return the jumpBig
	 */
	public Animation getJumpBig() {
		return jumpBig;
	}

	/**
	 * @param jumpBig
	 *            the jumpBig to set
	 */
	public void setJumpBig(Animation jumpBig) {
		this.jumpBig = jumpBig;
	}

	/**
	 * @return the jumpFire
	 */
	public Animation getJumpFire() {
		return jumpFire;
	}

	/**
	 * @param jumpFire
	 *            the jumpFire to set
	 */
	public void setJumpFire(Animation jumpFire) {
		this.jumpFire = jumpFire;
	}

	/**
	 * @return the dead
	 */
	public Animation getDead() {
		return dead;
	}

	/**
	 * @param dead
	 *            the dead to set
	 */
	public void setDead(Animation dead) {
		this.dead = dead;
	}

	/*
	 * @Override public void setCurrent(Animation a){ super.setCurrent(a); }
	 */

}
